package www.openteam.com.presenter.business.other;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.SomeCustomInfo;
import www.openteam.com.contract.business.other.SearchSomeCustomInfoContract;
import www.openteam.com.model.business.other.SearchSomeCustomInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.SearchCustomFragment;

/**
 * Created by kylin on 2016/11/25.
 */

public class SearchSomeCustomInfoPresenter extends BasePresenter<SearchCustomFragment>
        implements SearchSomeCustomInfoContract.SearchSomeCustomInfoPresenter {
    public void querySomeCustomInfo(String name, int pageSize) {
        ((SearchSomeCustomInfoModel) getiModelMap().get("searchSomeCustom"))
            .querySomeCustomInfo(name, pageSize, new SearchSomeCustomInfoModel.SearchSomeCustomInfoOnListener() {
                @Override
                public void querySCISuccess(SomeCustomInfo pbProductInfo) {
                    getIView().loadSCIData(pbProductInfo);
                }

                @Override
                public void querySCIFail(Throwable throwable) {
                    getIView().hideSCIData(throwable);
                }
            });
    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new SearchSomeCustomInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("searchSomeCustom", models[0]);
        return hashMap;
    }
}
